package org.apache.ibatis.demo.test;

import org.apache.ibatis.demo.dao.BlogMapper;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.SimpleExecutor;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.session.*;
import org.apache.ibatis.session.SqlSession;

import org.apache.ibatis.transaction.Transaction;
import org.apache.ibatis.transaction.jdbc.JdbcTransaction;
import org.junit.Before;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.LinkedList;
import java.util.List;

import static org.h2.message.Trace.JDBC;

/**
 * @Date 2021/2/16 22:10
 * @Created mobian
 * @Description MyBatis测试代码的第一个测试案例
 */
public class Demo01 {
  public static void main(String[] args) throws IOException {


    String resource = "resources/mybatis-config.xml";
    InputStream inputStream = Resources.getResourceAsStream(resource);

    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    //对我们执行器进行一个初始化
    SqlSession sqlSession = sqlSessionFactory.openSession();

    sqlSession.selectList("org.apache.ibatis.demo.dao.BlogMapper.selectBlog");
//    sqlSession.commit();
//    sqlSession.selectList("org.apache.ibatis.demo.dao.BlogMapper.selectBlog");

    sqlSession.close();



  }
}
